"use strict";
/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.createTable("Roles", {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER.UNSIGNED,
        comment: "角色ID",
      },
      name: {
        allowNull: false,
        type: Sequelize.STRING(20),
        comment: "角色名称",
      },
      code: {
        allowNull: false,
        type: Sequelize.STRING(45),
        comment: "角色编码",
      },
      remark: {
        type: Sequelize.TEXT,
        comment: "角色备注",
      },
      status: {
        allowNull: false,
        defaultValue: false,
        type: Sequelize.BOOLEAN,
        comment: "用户状态，是否启用",
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE,
        comment: "创建时间",
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE,
        comment: "更新时间",
      },
    });
    await queryInterface.addIndex("Roles", {
      fields: ["code"],
      unique: true,
    });
  },
  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable("Roles");
  },
};
